<?
layout("/inc/win_layout.html",{title:sysTitle}){
?>
	<link rel="stylesheet" href="static/uploadify/uploadify.css" type="text/css"></link>
	<script type="text/javascript" src="static/uploadify/jquery.uploadify.min.js"></script>
    <script type="text/javascript" src="static/utf8-jsp/ueditor.config.js"></script>
	<script type="text/javascript" src="static/utf8-jsp/ueditor.all.js"></script>
	<script type="text/javascript" src="static/utf8-jsp/lang/zh-cn/zh-cn.js"></script>
	<script type="text/javascript" src="static/utf8-jsp/third-party/video-js/video.js"></script>
	<style>
		/* .vali_pass {   
			width: 350px;   
			margin: 0 auto;   
			padding: 10px;   
			border: #eee 1px solid; 
			height: 10%; 
			text-align: center; 
		}  */
		.vali_pass_progress {
			width: 350px; 
			border: #eee 1px solid;
		    margin - top: 0px;
		    background - color: #efefef;
		    height: 10px;
		    border - radius: 5px;
		}
		.vali_pass_inner_progress {
		    display: block;
		    height: 100 % ;
		    background - color: transparent;
		    /* border - radius: 5px; */
		    width: 100 % ;
		}
		.error {  background-color: #ff3300; }
		.middle {  background-color: gold; } 
		.strong {  background-color: green; } 
	</style>
<div id="page-wrapper" style="margin-left: 0px; ">

	<!--BEGIN CONTENT-->
	<div class="page-content"
		style="min-height: auto;padding-bottom: 20px; height: 300px; overflow: auto;">

		<div class="row mbl">
			<input id="balance" type="hidden" class="form-control" value="0" />
			<input id="payment" type="hidden" class="form-control" value="0" />
			<input id="buttonType" type="hidden" class="form-control" value="0" />
			<div class="panel">
				<div class="panel-body pan">
					<table width="100%">
						<tr style="height:50px;">
							<td width="20%" align="right">类型：</td>
							<td ><button type="button" class="btn btn-sm btn-primary" onclick="firstPassword()" style="height:30px;width: 80px" id="fPassword">初始密码</button>&nbsp;<span id="briefnessPassword"></span>&nbsp;&nbsp;<button type="button" onclick="oneselfSetting()" class="btn btn-sm btn-primary" style="height:30px;width: 80px" id="pSetting">人工设定</button></td>
						</tr>
						<tr style=" height:50px;">
							<td align="right">密码：</td>
							<td>
								<input type="text" id="newPassword" name="pass" style=" height:40px;width:60%" > 
								<button type="button" style=" background-color: #efefef; border-color: #e5e5e5; color: #777777;" class="btn btn-sm btn-primary"  onclick = "copyPassword()" >复制</button>&nbsp;&nbsp;
								<button onclick="clearPassword()" style=" background-color: #efefef; border-color: #e5e5e5; color: #777777;" class="btn btn-sm btn-primary"  type="button">清空</button>
							</td>
						</tr>
						<tr style=" height:50px;">
							<td align="right">密码强度：</td>
							<td>
								<!-- <div class="vali_pass">  --> 
									<!-- <div class="vali_pass_progress">   -->  
										<span id="passShow" class="vali_pass_progress vali_pass_inner_progress"></span>   
									<!-- </div> -->
								<!-- </div>   -->
							</td>
						</tr>
					</table>
					<!-- <div class="row" style="margin-bottom: 10px;">
						<div class="col-lg-6"
							style="/* width: 400px; */ text-align:center /* float:center; margin-right:-20px;  */">
							<label for="inputUsername" class="col-md-3 control-label" style="margin:0 auto">类型：</label>
							<button type="button" >默认</button>
							<button type="button" >默认</button>
						</div>
					</div> -->
				</div>
			</div>


		</div>


	</div>

	<!--END CONTENT-->
</div>


<?} ?>
<script>
	var index1 = window.parent.getlay();
	var ele_pass = document.getElementById("newPassword");
	var ele_progress = document.getElementsByClassName("vali_pass_inner_progress")[0];
	var begin_classname = ele_progress.className;
	var regxs = [];
	regxs.push(/[^a-zA-Z0-9_]/g);
	regxs.push(/[a-zA-Z]/g);
	regxs.push(/[0-9]/g);
	ele_pass.onkeyup = function() {
	    var val = this.value;
	    var len = val.length;
	    var sec = 0;
	    if (len >= 6) { // 至少六个字符     
		    for (var i = 0; i < regxs.length; i++) {
		        if (val.match(regxs[i])) {
		            sec++;
		        }
		    }
		}
		var result = (sec / regxs.length) * 100;
		ele_progress.style.width = result + "%";
		if (result > 0 && result <= 50) {
		    ele_progress.setAttribute("class", begin_classname + " error");
		} else if (result > 50 && result < 100) {
		    ele_progress.setAttribute("class", begin_classname + " middle");
		} else if (result == 100) {
		    ele_progress.setAttribute("class", begin_classname + " strong");
		}
	}
	/* 复制密码框内容 */
	function copyPassword(){
		/* var copyPass = document.getElementById("newPassword");
		copyPass.select(); // 选择对象
		document.execCommand("Copy"); // 执行浏览器复制命令 */
		if($("#buttonType").val()==1){
			document.getElementById('newPassword').disabled = false;
		}
		$("#newPassword").select();
		document.execCommand("copy",false,null);
		if($("#buttonType").val()==1){
			document.getElementById('newPassword').disabled = true;
		}
		
	}
	/* 清空密码框 */
	function clearPassword(){
		$("#fPassword").css("background-color","red");
		$("#pSetting").css("background-color","red");
		$("#fPassword").css("border-color","red");
		$("#pSetting").css("border-color","red");
		$("#passShow").width(0);
		$("#passShow").attr("class", begin_classname);
		/* ele_progress.style.width = 0%;
		ele_progress.setAttribute("class", begin_classname ); */
		$("#newPassword").val("");
		$("#buttonType").val("");
		document.getElementById('newPassword').disabled = false;
		$("#briefnessPassword").html('');
	}
	/* 设置初始化密码 */
	function firstPassword(){
		$("#fPassword").css("background-color","green");
		$("#pSetting").css("background-color","red");
		$("#fPassword").css("border-color","green");
		$("#pSetting").css("border-color","red");
		document.getElementById('newPassword').disabled = true;
		$("#newPassword").val("123456");
		$("#passShow").css("width","33.3%");
		$("#passShow").attr("class", begin_classname + " error");
		$("#buttonType").val("1");
		/* $("#briefnessPassword").html('初始密码为123456'); */
	}
	/*人工设定密码*/
	function oneselfSetting(){
		if($("#buttonType").val()==1){
			clearPassword();
		}
		$("#fPassword").css("background-color","red");
		$("#pSetting").css("background-color","green");
		$("#fPassword").css("border-color","red");
		$("#pSetting").css("border-color","green");
	}
	function UpdatePassword(){
		if(ele_pass.value.length<6){
			alert('请输入6位以上密码');
			return null;
		}
		var reg =new RegExp("[\u4e00-\u9fa5]");
		if(reg.test($("#newPassword").val())){
	      	alert('密码只能包含数字、字母或者特殊符号！');
	      	clearPassword();
			return null;
	    }
		$.ajax({
			type : "post",
			url : "./userUpdatePassword.do",
			data : {
				'id':index1,
				'newPassword':$("#newPassword").val()
			},
			dataType : "json",
			async : false,
			success : function(data) {
				var index = parent.layer.getFrameIndex(window.name);
				window.parent.get();
				parent.layer.msg('提交成功');
				parent.layer.close(index);
			},
			error : function(data) {
				alert("请求失败");
			}
		})
	}
	/* 
	$(function() {
		if (index1 != 0) {
			$("#passwordParent").hide();
			$.ajax({
				type : "post",
				url : "./memberUpdate.do",
				data : {
					"id" : index1,
				},
				dataType : "json",
				async : false,
				success : function(data) {
					$("#username").val(data[0].username);
					$("#password").val(data[0].password);
					document.getElementById('password').disabled = true;
					$("#nickname").val(data[0].nickname);
					$("#realname").val(data[0].realname);
					$("#type").val(data[0].type);
					$("#createTime").val(data[0].createTime);
					$("#createIpAddress").val(data[0].createIpAddress);
					$("#avatarImg").val(data[0].avatarImg);
					$("#single").html("<img src='"+data[0].avatarImg+"' width='30' height='30'/>");
					$("#email").val(data[0].email);
					$("#education").val(data[0].education);
					$("#profession").val(data[0].profession);
					$("#researchField").val(data[0].researchField);
					$("#status").val(data[0].status);
					$("#mobilephone").val(data[0].mobilephone);
					$("#workunit").val(data[0].workunit);
					$("#title").val(data[0].title);
					$("#certificateType").val(data[0].certificateType);
					$("#certificateNumber").val(data[0].certificateNumber);
					$("#balance").val(data[0].balance);
					$("#payment").val(data[0].payment);

				},
				error : function(data) {
					alert("请求失败");
				}
			});
		}
		
		 _editor = UE.getEditor('uploadImage');
	    _editor.ready(function (){
	        //设置编辑器不可用(事实上不可以设置不可用...所以注释掉,以观后效)
	        _editor.setDisabled();
	        //隐藏编辑器,因为只使用上传功能
	        _editor.hide();
	        //侦听图片上传
	  	 	_editor.addListener('beforeInsertImage',function(t,arg){
	  	 			for(var i=0;i<arg.length;i++){
	  	 				var urlPath = arg[i].src;
	  	 				$("#avatarImg").val(urlPath);
						$("#single").html("<img src='"+urlPath+"' width='30' height='30' />");
	  	 			}
	        });
	        //侦听文件上传
		   	 _editor.addListener('afterUpfile',function(t,arg){
		   	 	
		   	 });
	   }); 
	});
 	//上传图片
	function upImages() {
		var myFiles = _editor.getDialog("insertimage");
	  		myFiles.open();
	   
	}
	function Page() {
		if ($.trim($("#username").val()).length < 1) {
			alert('用户名不能为空！');
			return null;
		}
		if ($.trim($("#password").val()).length < 1 && index1 == 0) {
			alert('密码不能为空！');
			return null;
		}
		if ($.trim($("#mobilephone").val()).length < 1) {
			alert('手机号不能为空！');
			return null;
		}

		if ($.trim($("#status").val()).length < 1) {
			alert('请选择状态！');
			return null;
		}

		$.ajax({
			type : "post",
			url : "./userAddUpdate.do",
			data : {
				"id" : index1,
				"username" : $("#username").val(),
				"password" : $("#password").val(),
				"nickname" : $("#nickname").val(),
				"realname" : $("#realname").val(),
				"mobilephone" : $("#mobilephone").val(),
				"createIpAddress" : $("#createIpAddress").val(),
				"email" : $("#email").val(),
				"avatarImg" : $("#avatarImg").val(),
				"createTime" : $("#createTime").val(),
				"status" : $("#status").val(),
				"education" : $("#education").val(),
				"profession" : $("#profession").val(),
				"researchField" : $("#researchField").val(),
				"workunit" : $("#workunit").val(),
				"title" : $("#title").val(),
				"certificateType" : $("#certificateType").val(),
				"certificateNumber" : $("#certificateNumber").val(),
				"type" : $("#type").val(),
				"balance" : $("#balance").val(),
				"payment" : $("#payment").val(),
			},
			dataType : "json",
			async : false,
			success : function(data) {
				var index = parent.layer.getFrameIndex(window.name);
				window.parent.get();
				parent.layer.msg('提交成功');
				parent.layer.close(index);
			},
			error : function(data) {
				alert("请求失败");
			}
		});
	}
	function newdate() {
		$.getJSON('./newDate.do', {}, function(res) {
			$("#createTime").val(res.date);
		});
	}; */
</script>